<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" placeholder="qingshuru ">

    <script>
        //onkeydown  按下
        // onkeyup  抬起
        let inp = document.querySelector("input")
        inp.onkeydown = function (e) {
            console.log(123);
            console.log("键盘抬起",e.keyCode);
            if(e.keyCode == 13){
                alert("gun")
            }
            document.onkeydown = function(){
                 if(e.keyCode == 123){
                alert("gun")
                e.preventDefault()
                return false
            }
            }
            

        }
    </script>
</body>

</html>